import Vue from 'vue';
import VueRouter from 'vue-router';
import Layout from '../views/layout/Layout.vue'

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    redirect: 'index',
    component: Layout,
    meta: {title: '首页', icon: 'home'},
    children: [
      {
        path:'index',
        name:'index',
        component: ()=> import('../views/index.vue'),
        hidden: true
      }
    ]
  },
  {
    path: '/menu',
    component: Layout,
    redirect: '/menu/list',
    meta: {title: '菜单管理', icon: 'menu'},
    children: [
      {
        path:'list',
        name:'resourceList',
        component: () => import('../views/menu/list.vue'),
        hidden: true
      }
    ]
  },
  {
    path: '/role',
    component: Layout,
    redirect: '/role/list',
    meta: {title: '角色管理', icon: 'role'},
    children: [
      {
        path:'list',
        name:'roleList',
        component: () => import('../views/role/list.vue'),
        hidden: true
      }
    ]
  },
  {
    path: '/dict',
    component: Layout,
    redirect: '/dict/list',
    meta: {title: '字典管理', icon: 'dict'},
    children: [
      {
        path:'list',
        name:'roleList',
        component: () => import('../views/dict/list.vue'),
        hidden: true
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    meta: {title: '用户管理', icon: 'user'},
    children: [
      {
        path:'list',
        name:'userList',
        component: () => import('../views/user/list.vue'),
        hidden: true
      }
    ]
  }

];

const router = new VueRouter({
  mode: 'history',
  routes,
  watch: {
    '$route'(to, from) {
      this.$router.go(0);
    }
  },
});

export default router
